package com.duqc.zk;

import lombok.extern.slf4j.Slf4j;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;

/**
 * @ClassName MyWatcher
 * @Description TODO
 * @Author duqc
 * @Date 2021/5/13
 **/
@Slf4j
public class MyWatcher implements Watcher {

    @Override
    public void process(WatchedEvent watchedEvent) {
        //获取事件类型
        Event.EventType type = watchedEvent.getType();
        //通知状态
        Event.KeeperState state = watchedEvent.getState();
        //节点路径
        String path = watchedEvent.getPath();

        log.info("监听到的事件类型:" + type.name());
        log.info("监听到的通知状态:" + state.name());
        log.info("监听到的ZNODE路径:" + path);

    }

}
